version: '3'

services:

  redis:
    image: redis
    ports:
      - '6379:6379'

  db:
    image: postgres
    env_file:
      - .env
    environment:
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - pg_data:/var/lib/postgresql/data/pgdata
    ports:
      - '5432:5432'
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U postgres" ]
      interval: 10s
      timeout: 5s
      retries: 5

  app:
    build: .
    tty: true
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - '8011:8000'
    volumes:
      - .:/code
    depends_on:
      db:
        condition: service_healthy

  celery:
    build: .
    tty: true
    command: celery -A config worker -l INFO
    depends_on:
      - redis
      - app

  celery_beat:
    build: .
    restart: always
    tty: true
    command: celery -A config beat -l INFO -S django
    depends_on:
      - redis
      - app

volumes:
  pg_data: